<template>
    <div class="home">
        <button @click="ajaxData">初始化数据</button>
        {{ users.length }}
        <!-- <img alt="Vue logo" src="../assets/logo.png" /> -->
        <div>
            <el-table :data="tableData" stripe style="width: 100%">
                <el-table-column prop="date" label="日期" width="180"> </el-table-column>
                <el-table-column prop="name" label="姓名" width="180"> </el-table-column>
                <el-table-column prop="address" label="地址"> </el-table-column>
                <el-table-column prop="age" label="年龄"> </el-table-column>
            </el-table>
        </div>
    </div>
</template>

<script>
// @ is an alias to /src
import { add } from '@/utils/index.js';

let a = add(1, 2);
export default {
    name: 'Home',
    data() {
        return {
            a: a,
            users: [],
            tableData: [
                {
                    date: '2023-01-02',
                    name: '大伟聊前端',
                    address: '北京',
                    age: 18
                },
                {
                    date: '2023-01-04',
                    name: '大伟聊前端',
                    address: '北京',
                    age: 18
                },
                {
                    date: '2023-01-01',
                    name: '大伟聊前端',
                    address: '北京',
                    age: 18
                },
                {
                    date: '2023-01-03',
                    name: '大伟聊前端',
                    address: '北京',
                    age: 18
                }
            ]
        };
    },
    components: {
        // HelloWorld
    },
    methods: {
        ajaxData() {
            const res = [];
            for (let i = 0; i < 100000; i++) {
                res.push({
                    id: i,
                    userName: `大伟聊前端${i}`,
                    info: {
                        age: 18,
                        address: '中国--北京'
                    },
                    ext: {
                        date: new Date(),
                        office: '字节跳动',
                        level: '前端开发',
                        blog: 'abc.com',
                        like: {
                            name: '篮球'
                        }
                    }
                });
            }
            this.users = res;
            console.log(this.users);
            return res;
        }
    },
    async created() {
        // const users = await axios.get("/api/users");
        // this.users = users;
    }
};
</script>
